package cn.dzhang.spring.boot.repository;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import cn.dzhang.spring.boot.model.Role;

public interface RoleRepository extends JpaRepository<Role, Integer> {

	@Query(value = "SELECT * FROM tbl_role r, tbl_user_role ur WHERE ur.tbl_role_id=r.id AND ur.tbl_user_id = ?1", nativeQuery = true)
	List<Role> findByUserId(Integer userId);
}
